using Microsoft.Win32;

namespace Triumph
{
    partial class Form1
    {
        RegistryKey MainKey = Registry.CurrentUser;
        string defVal = @"Software\Cosa Nostra\Triumph";

        private RegistryKey GetKey(string where)
        {
            if (where.Length > 0)
                where = where.StartsWith(@"\") ? where : @"\" + where;

            return MainKey.CreateSubKey(defVal + where);
        }

        private void RegSetValue(string where, string name, object info)
        {
            GetKey(where).SetValue(name, info);
        }

        private object RegGetValue(string where, string name, object defaultValue)
        {
            return GetKey(where).GetValue(name, defaultValue);
        }

        private object[] RegGetValues(string where, string name, object defaultValue)
        {
            object[] retVals = new object[GetKey(where).GetValueNames().GetUpperBound(1)];

            int iCnt = 0;
            foreach (string key in GetKey(where).GetValueNames())
            {
                retVals[iCnt] = GetKey(where).GetValue(key, defaultValue);
                iCnt++;
            }

            return retVals;
        }
    }
}